﻿
// ReSharper disable AutoPropertyCanBeMadeGetOnly.Global

namespace KinonekoSoftware.Foundation.Markups
{
    public class ColorExtension: MarkupExtension
    {
        public ColorExtension()
        {
            Opacity = 1d;
        }

        public ColorExtension(BrushKey theme)
        {
            Theme = theme;
            Opacity = 1d;
        } 
        
        public override object ProvideValue(IServiceProvider serviceProvider)
        {
            ThemeSystem.GetARGB(Xplat.Theme.Colors[Theme],out var a, out var r, out var g, out var b);
            
#if AVALONIA
            return new Color(
                a,
                r,
                g, 
                b);
#else
            return new Color
            {
                A = a,
                R = r,
                G = g,
                B = b,
            };
#endif
        }
        
        public BrushKey Theme { get; set; }
        public double Opacity { get; set; }
    }
}